set doc off
set verify off
set serveroutput on size 1000000

declare   
    l_total_extracted_sets	NUMBER;
	l_total_imported_sets 	NUMBER;
	
	l_total_extracted_option	NUMBER;	
	l_total_imported_option		NUMBER;
	
	l_func_id					VARCHAR2(100):='CAPGLREC_AUTOPOST';	       

begin
	 select count(1)
	 into   l_total_extracted_sets
     from   gl_automatic_posting_sets 
     where  set_of_books_id = (select set_of_books_id 
                               from   gl_sets_of_books 
                               where  upper(short_name) = upper('&1'));

	SELECT COUNT(1) 
	INTO l_total_imported_sets
	from CRST_GL_AUTO_POSTING_SETS;

	 select count(1)
	 into   l_total_extracted_option
     from   gl_automatic_posting_options o,
     		gl_automatic_posting_sets s
     where  o.autopost_set_id =s.autopost_set_id
     and 	s.set_of_books_id = (select set_of_books_id 
                                from   gl_sets_of_books 
                               where  upper(short_name) = upper('&1'));
		
	SELECT COUNT(1) 
	INTO l_total_imported_option
	from CRST_GL_AUTO_POSTING_OPTS;
	
	dbms_output.put_line('Function: '||l_func_id);		
	dbms_output.put_line('Total Extracted (Posting Sets): '||TO_CHAR(l_total_extracted_sets)) ;
	dbms_output.put_line('Total Imported (Posting Sets):  '||TO_CHAR(l_total_imported_sets));
	IF l_total_extracted_sets <> l_total_imported_sets THEN
		dbms_output.put_line('Error: No. of Records do not match!');
	END IF;		
	
	dbms_output.put_line('Total Extracted (Posting Option): '||TO_CHAR(l_total_extracted_option)) ;
	dbms_output.put_line('Total Imported (Posting Option):  '||TO_CHAR(l_total_imported_option));
	IF l_total_extracted_option <> l_total_imported_option THEN
		dbms_output.put_line('Error: No. of Records do not match!');
	END IF;			

end;
/


